package demo08;
class Money implements Cloneable{
    public double money = 15.8;
    //在这里实现对父类的克隆
    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}
public class Person implements Cloneable{
    public String name;
    public Money M;

    public Person(String name){
        this.name = name;
        this.M = new Money();
    }
    public String toString(){
        return "Person{" +"name = "+name+'\''+"}";
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
//        return super.clone();//克隆了一个模板
        Person temp = (Person) super.clone();
        temp.M = (Money) this.M.clone();//把当前对象的 M 克隆一份,当前对象是 person1
        return temp;
    }
}
